package models

import (
	"gorm.io/gorm"
	"heightFive/Day_exam/day3/userRpc/global"
)

type User struct {
	gorm.Model
	Name     string `gorm:"type:varchar(100)"`
	Password string `gorm:"type:varchar(100)"`
	Email    string `gorm:"type:varchar(100)"`
	Phone    string `gorm:"type:varchar(100)"`
	Address  string `gorm:"type:varchar(100)"`
}

func CreateUser(user User) (err error) {
	err = global.DB.Create(&user).Error
	return
}

func GetInfoByUsername(username string) (u User, err error) {
	err = global.DB.Where("name = ?", username).First(&u).Error
	return
}
